home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / putmsg.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  105 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: putmsg.c,v 1.5 1996/10/24 15:50:54 aros Exp $
  4.     $Log: putmsg.c,v $
  5.     Revision 1.5  1996/10/24 15:50:54  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:56:05  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:15  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include "exec_intern.h"
  20. #include <aros/libcall.h>
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <exec/ports.h>
  26.     #include <clib/exec_protos.h>
  27.  
  28.     AROS_LH2(void, PutMsg,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(struct MsgPort *, port,    A0),
  32.     AROS_LHA(struct Message *, message, A1),
  33.  
  34. /*  LOCATION */
  35.     struct ExecBase *, SysBase, 61, Exec)
  36.  
  37. /*  FUNCTION
  38.     Sends a message to a given message port. Messages are not copied
  39.     from one task to another but must lie in shared memory instead.
  40.     Therefore the owner of the message may generally not reuse it before
  41.     it is returned. But this depends on the two tasks sharing the message.
  42.  
  43.     INPUTS
  44.     port    - Pointer to messageport.
  45.     message - Pointer to message.
  46.  
  47.     RESULT
  48.  
  49.     NOTES
  50.     It is legal to send a message from within interrupts.
  51.  
  52.     Messages may either trigger a signal at the owner of the messageport
  53.     or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
  54.  
  55.     EXAMPLE
  56.  
  57.     BUGS
  58.  
  59.     SEE ALSO
  60.     WaitPort(), GetMsg()
  61.  
  62.     INTERNALS
  63.  
  64.     HISTORY
  65.  
  66. ******************************************************************************/
  67. {
  68.     AROS_LIBFUNC_INIT
  69.  
  70.     /*
  71.     Messages may be sent from interrupts. Therefore the message list
  72.     of the message port must be protected with Disable().
  73.     */
  74.     Disable();
  75.  
  76.     /* Set the node type to NT_MESSAGE == sent message. */
  77.     message->mn_Node.ln_Type=NT_MESSAGE;
  78.  
  79.     /* Add it to the message list. */
  80.     AddTail(&port->mp_MsgList,&message->mn_Node);
  81.  
  82.     /* And trigger the action. */
  83.     switch(port->mp_Flags&PF_ACTION)
  84.     {
  85.     case PA_SIGNAL:
  86.     /* Send the signal */
  87.     Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
  88.     break;
  89.  
  90.     case PA_SOFTINT:
  91.     /* Raise a software interrupt */
  92.     Cause((struct Interrupt *)port->mp_SoftInt);
  93.     break;
  94.  
  95.     case PA_IGNORE:
  96.     /* Do nothing. */
  97.     break;
  98.     }
  99.  
  100.     /* All done. */
  101.     Enable();
  102.     AROS_LIBFUNC_EXIT
  103. }
  104.  
  105.